<template>
  <view class="companyDetails">
    <view class="companyDe">
      <view class="companyDeTitle">{{ companyUnitsList.name }}</view>
      <view>
        <img class="companyDeImg" :src="companyUnitsList.logo" alt />
      </view>
    </view>
    <view class="companyDeIntro">
      <text v-if="companyUnitsList.companyIndustryFirst">{{ companyUnitsList.companyIndustryFirst }}</text>
      <text v-if="companyUnitsList.properties" class="marginLeft9">{{ companyUnitsList.properties }}</text>
      <text v-if="companyUnitsList.personSize" class="marginLeft9">{{ companyUnitsList.personSize | filPersonSize }}人</text>
    </view>
    <view class="recruitDetailsZWMS">
      <text class="zwmsBorder"></text>公司地址
    </view>
    <view class="companyAd" v-if="companyUnitsList.address">
      <text :key="z" v-for="z in companyUnitsList.address.split(',').splice(1)">{{ z }}</text>
    </view>
    <view class="recruitDetailsZWMS">
      <text class="zwmsBorder"></text>在招职位
      <text>{{ listAll.length }}个</text>
    </view>
    <view class>
      <view class="contentHoConBack" v-for="i in listAll" :key="i">
        <view class="contentHoConBackTop">
          <view class="contentHoConBackTop1">{{ i.postName }}</view>
          <view class="contentHoConBackTop3">
           <span v-if="i.lowestSalary === i.highestSalary">{{ i.highestSalary }}元</span>
              <span v-else>{{ i.lowestSalary }}-{{ i.highestSalary }}元</span>
              <text>/{{ salaryGrantTypeArr[i.salaryGrantType] }}</text>
          </view>
        </view>
        <view class="contentHoConBackName paddtop10">
          <text>{{ i.companyName }}</text>
          <text class="paddLeft" :key="z" v-for="z in i.cityName.split(',').splice(1)">{{ z }}</text>
        </view>
        <view class="paddtop" v-if="i.highlights">
          <text class="contentHoConBackTitle" :key="z" v-for="z in i.highlights.split(',')">{{ z }}</text>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import { companyUnits, listAllByIsCancel } from "./api";
import { mapState } from "vuex";
export default {
  data() {
    return {
      salaryGrantTypeArr: ["小时", "日", "月", "年"],
      listAll: [],
      companyUnitsList: {}
    };
  },
  computed: {
    ...mapState(["user", "jobSeeker"]),
    ...mapState(["site"])
  },
  onLoad(e) {
    companyUnits(e.companyUnitId)
      .then(res => {
        this.companyUnitsList = res;
        console.log(res);
        const data = {
          companyUnitsId: this.companyUnitsList.id,
          isEmp:1,
          empCompanyId: this.site.companyId
        };
        listAllByIsCancel(this.companyUnitsList.id, data)
          .then(res => {
            this.listAll = res;
            console.log(res);
          })
          .catch(err => {
            console.log(err);
          });
      })
      .catch(err => {
        console.log(err);
      });
  },
  filters: {
    filPersonSize(val) {
      if (val === 1) {
        return "0-20";
      } else if (val === 2) {
        return "20-99";
      } else if (val === 3) {
        return "99-200";
      } else if (val === 4) {
        return "200-500";
      } else if (val === 5) {
        return "500-1000";
      } else if (val === 6) {
        return "1000以上";
      } else {
        return "";
      }
    }
  },
  methods: {
    // goCompany() {
    //   uni.navigateTo({
    //     url: `/pages/company/companyDetails/companyDetails`
    //   });
    // }
  }
};
</script>

<style lang="scss">
@import "../../../styles/styles.scss";
@import "./index.scss";
</style>
